#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import queue
import time
import threading

qu = queue.Queue()

def do_job():
    while True:
        i = qu.get()
        time.sleep(1)
        print("index: {0} 当前: {1}".format(i, threading.current_thread()))
        qu.task_done()

if __name__ == '__main__':
    for i in range(3):
        t = threading.Thread(target=do_job)
        t.setDaemon(True)
        t.start()

    time.sleep(3)
    # 模拟创建线程池3秒后塞进10个任务到队列
    for i in range(10):
        qu.put(i)

    qu.join()
